﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RTGS.Library.Report;
using RTGS.Library.DataAccess.Rtgs;
using RTGS.Library.DataAccess.UserManagement;
using RTGS.Library.Entities.UserManagement;
using System.Configuration;
using Microsoft.Reporting.WebForms;
using RTGS.Web;

public partial class report_reportOutgoing : BasePage
{
    ReportSptDetailRecordO reportDal = new ReportSptDetailRecordO(ConfigurationManager.ConnectionStrings["Rtgs"].ConnectionString);
   // private stpLogRepo stpLogDal = new stpLogRepo(ConfigurationManager.ConnectionStrings["Rtgs"].ConnectionString);

    private sysTLogRepo logDal = new sysTLogRepo(ConfigurationManager.ConnectionStrings["Rtgs"].ConnectionString);
    private sysTLog log = new sysTLog();
    private string status = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Context.Request.Params["status"] != null)
                    status = Context.Request.Params["status"].Trim();

                DataTable dt = reportDal.GetReportOutgoing(status);

                rsViewer.Reset();
                rsViewer.LocalReport.ReportPath = Server.MapPath("~/reportviewer/rptOutgoing.rdlc");
                ReportDataSource rds = new ReportDataSource();
                rds.Name = "DataSet1";
                rds.Value = dt;

                ReportParameter[] param = new ReportParameter[1];
                param[0] = new ReportParameter("userid", this.UserLoggedIn);
                //param[1] = new ReportParameter("semester", semester);
                //param[2] = new ReportParameter("eselon", eselon);
                //param[3] = new ReportParameter("wilayah", wilayah);
                //param[4] = new ReportParameter("uakpb", satker);

                rsViewer.LocalReport.SetParameters(param);


                rsViewer.LocalReport.DataSources.Clear();
                rsViewer.LocalReport.DataSources.Add(rds);
                rsViewer.LocalReport.Refresh();

                log = new sysTLog();
                log.logEvent = "View Report Outging Success";
                log.logMessage = string.Empty;

            }
            catch (Exception ex)
            {
                log = new sysTLog();
                log.logEvent = "View Report Outging Error";
                log.logMessage = ex.Message;

                Response.Write(ex.Message);

            }
            finally
            {
                log.logSource = "reportOutgoing.aspx";
                log.createdBy = base.UserLoggedIn;
                log.createdDate = DateTime.Now;
                logDal.Save(log);
            }
        }
    }
}